#!/usr/bin/python3
# -*- coding: utf-8; tab-width: 4; indent-tabs-mode: t -*-

import os
import sys
import shutil
import argparse
sys.path.append('/usr/lib/partner')
from ass_util import AssUtil
from ass_param import AssParam
from ass_daemon import AssDaemon

# parse parameter
parseResult = None
if True:
    argParser = argparse.ArgumentParser()
    argParser.add_argument("--user", action="store_true")
    argParser.add_argument("--pid-file", dest='pid_file', help="Specify location of a PID file.")
    argParser.add_argument("-d", "--debug-level", dest='debug_level',
                           choices=['CRITICAL', 'ERROR', 'WARNING', 'INFO', 'DEBUG'], default="INFO",
                           help="Set output debug message level")
    parseResult = argParser.parse_args()

param = AssParam(parseResult.user)

# fill AssParam according to argument
if parseResult.pid_file is not None:
    param.pidFile = parseResult.pid_file
param.logLevel = parseResult.debug_level

# start server
daemon = AssDaemon(param)
daemon.run()
sys.exit(0)
